Sound Commands
|
Either you're making multimedia
presentation or player, sound features
are important part of entire story.
MMB comes with variety of
sound-related script commands, dealing
with:
-
Audio Volume
-
Sound playback of
following formats:
MPG, MP1, MP2, MP3, OGG,
WMA, ASF, WAV, MID, RMI, MOD, S3M,
XM, IT
-
Audio CD
playback
-
Audio
Visualization
|
|
|
|
Increases
Master
Volume
by
5%
if
no
percentage
is
specified
through
command
parameter.
Otherwise
sets
volume
to
specified
percentage
value
in
range:
0-100
|
|
|
|
|
**Increase
volume
without
custom
percentage:
VolumeUp()
**Set
volume
to
70%:
VolumeUp("70")
**Set
volume
to
20%
using
numerical
variable:
volume=20
VolumeUp("volume")
|
|
|
|
|
Master
volume
is
an
output
audio
volume
for
all
mixer
lines.
|
|
|
|
|
|
Decreases
Master
Volume
by
5%
.
No
parameters
required.
|
|
|
|
|
**Decrease
Master
Volume:
VolumeDown()
|
|
|
|
|
Master
volume
is
an
output
audio
volume
for
all
mixer
lines.
|
|
|
|
|
|
Displays
FMOD
library
configuration
dialog
box,
giving
users
ability
to
set
output
sound
driver
and
device.
MMB
also
allows
setting
configuration
through
this
script
command.
If
you
call
FMODConfig
command
without
parameters...
FMODConfig("")
...configuration
dialog
box
will
appear:
As
already
mentioned
alternative,
configuration
can
be
set
through
FMODConfig
command
itself
using
parameters,
thus
avoiding
configuration
dialog
box.
There
are
two
parameters
separated
with
comma.
With
first
one
you
set
sound
output
driver
using
one
of
following
numbers:
1
-
DirectX
sound
2
-
Windows
Media
Wave
Out
3
-
No
Sound
With
second
parameter
you
set
status
of
MPEG
accurate
VBR
(
Variable
Bit
Rate)
timing:
0
-
MPEG
accurate
VBR
timing
off
1
-
MPEG
accurate
VBR
timing
on
Put
into
command,
parameters
look
like
this:
FMODConfig("1,0")
In
example
above,
green
number
represents
sound
output
driver
setting.
Red
number
represents
status
of
MPEG
accurate
VBR
timing.
|
|
|
|
|
**Show
FMOD
library
configuration
dialog
box:
FMODConfig("")
**Set
configuration
to
Windows
Media
Wave
output
driver
with
**MPEG
accurate
VBR
timing
off:
FMODConfig("2,0")
**Set
configuration
to
DirectX
Sound
output
driver
with
**MPEG
accurate
VBR
timing
on:
FMODConfig("2,1")
|
|
|
|
|
Configuration
dialog
box
is
displayed
on
top
and
project's
window
can't
be
used
until
user
closes
dialog
box.
|
|
|
|
|
|
Plays
any
supported
type
of
sound
file
(MP3,
Ogg,
WMA,
ASF,
Wave,
MOD,
MIDI)
specified
as
command
parameter.
Sound
file
parameter
should
contain
either
a)
folder
path
+
sound
file
name,
or
b)
path
macro
+
sound
file
name
|
|
|
|
|
**Play
MP3
sound
file
MyMusic.mp3
from
folder
c:\My
Project
PlaySound("c:\My
Project\MyMusic.mp3")
**Play
WAVE
sound
file
tada.wav
from
Window's
media
folder:
PlaySound("<Windows>\Media\tada.wav")
**Play
MIDI
sound
file
Autumn.mid
from
<SrcDir>
folder:
PlaySound("<SrcDir>\Autumn.mid")
|
|
|
|
|
|
|
This
command not only
stops playback of
all audio files
but it also unload
the files from memory.
|
|
|
|
|
**Stop
sound
playback:
StopSound()
|
|
|
|
|
This
command
stops
playback
of
all
sound
files,
including
background
sound
(if
used).
|
|
|
|
|
|
Opens
and
plays
MP3,
OGG,
WMA
or
ASF
sound
file
specified
as
a
command
parameter.
Sound
file
parameter
should
contain
either
a)
folder
path
+
sound
file
name,
or
b)
path
macro
+
sound
file
name
|
|
|
|
|
**Play
MP3
sound
file
MyMusic.mp3
from
folder
c:\My
Project
AudioOpen("c:\My
Project\MyMusic.mp3")
**Play
WMA
sound
file
FourSeasons.wma
from
<SrcDir>
folder:
AudioOpen("<SrcDir>\FourSeasons.wma")
|
|
|
|
|
Use
CBK
contants
to
retrieve
info
on
opened
sound
file.
If
file
has
not
been
specified
as
a
command
parameter,
MMB
will
display
Open
File
dialog
box.
Multiple
file
selections
are
enabled
(using
CTRL
and
SHIFT
keys)
-
first
selected
file
will
be
played,
others
are
stored
in
MMB's
internal
Song
List
and
are
retrievable
through
the
<List>
constant.
|
|
|
|
|
|
Plays
MP3,
OGG,
WMA
or
ASF
sound
file
specified
using
AudioOpen
command.
|
|
|
|
|
**Play
opened
sound
AudioPlay(
)
|
|
|
|
|
|
|
Stops
playback
of
sound
opened
and
played
by
either
AudioOpen
or
AudioPlay
command.
No
parameters
required.
|
|
|
|
|
**Stop
sound
playback:
AudioStop()
|
|
|
|
|
|
Pauses
playback
of
sound
opened
and
played
by
either
AudioOpen
or
AudioPlay
command.
No
parameters
required.
|
|
|
|
|
**Pause
sound
playback:
AudioPause()
|
|
|
AudioRewind("Time","Parameters")
|
|
|
|
Rewinds
sound
opened
and
played
by
either
AudioOpen
or
AudioPlay
command
to
a
given
position
(in
seconds).
First
command
parameter
sets
number
of
seconds
for
rewinding.
Second
command
parameter
is
optional,
used
for
relative
rewinding,
and
to
use
it
set:
RELATIVE
...as
a
second
command
parameter.
|
|
|
|
|
**Rewind
audio
file
to
125th
second
AudioRewind("125","")
**Rewind
audio
file
for
20
seconds
using
relative
rewinding
AudioRewind("20","RELATIVE")
|
|
|
|
|
Learn
about
Matrix
object
to
create
a
seek
bar.
|
|
|
BackgroundPlay("Path","Parameters")
|
|
|
|
Opens
and
plays
any
type
of
supported
sound
file,
specified
as
command
parameter,
as
background
sound.
First
command
parameter
requires
either
a)
folder
path
+
sound
file
name,
or
b)
path
macro
+
sound
file
name
Second
command
parameter
is
optional
and
with
it
you
can
loop
(automatically
repeat)
playback
of
specified
sound
file.
Parameter
is:
LOOP
|
|
|
|
|
**Background
play
MP3
sound
file
MyMusic.mp3
from
<SrcDir>
folder
BackgroundPlay("<SrcDir>\MyMusic.mp3","")
**Background
play
WAV
sound
file
Beat.wav
from
<CD>
folder
in
loop
BackgroundPlay("<CD>\Beat.wav","LOOP")
|
|
|
|
|
|
|
Pauses
playback
of
sound
opened
and
played
by
BackgroundPlay
command.
No
parameters
required.
|
|
|
|
|
**Pause
background
sound
playback:
BackgroundPause()
|
|
|
|
|
|
Stops
playback
of
sound
opened
and
played
by
BackgroundPlay
command.
No
parameters
required.
|
|
|
|
|
**Stop
background
sound
playback:
BackgroundStop()
|
|
|
WavePlay("Path","Parameters")
|
|
|
|
Opens
and
plays
WAVE
sound
file
specified
as
a
command
parameter.
First
command
parameter
requires
either
a)
folder
path
+
sound
file
name,
or
b)
path
macro
+
sound
file
name
Second
command
parameter
is
optional
and
with
it
you
can
loop
(automatically
repeat)
playback
of
specified
sound
file.
Parameter
is:
LOOP
|
|
|
|
|
**Play
file
MyMusic.wav
from
folder
c:\My
Project
WavePlay("c:\My
Project\MyMusic.wav")
**Play
file
FourSeasons.wav
from
<SrcDir>
folder
with
looping:
WavePlay("<SrcDir>\FourSeasons.wav","LOOP")
**In
case of sound
file
is
embedded, don't
use the full
path..just name
of embedded
file defined
in the "Embedded
Sounds"
dialog:
WavePlay("FourSeasons","")
|
|
|
|
|
Use
CBK
contants
to
retrieve
info
on
opened
sound
file.
If
file
has
not
been
specified
as
command
parameter,
MMB
will
display
Open
File
dialog
box.
Multiple
file
selections
are
enabled
(using
CTRL
and
SHIFT
keys)
-
first
selected
file
will
be
played,
others
are
stored
in
MMB's
internal
Song
List
and
are
retrievable
through
the
<List>
constant.
|
|
|
|
|
|
Stops
playback
of
sound
opened
and
played
by
WavePlay
command.
No
parameters
required.
|
|
|
|
|
**Stop
wave
sound
playback:
WaveStop()
|
|
|
MidiPlay("Path","Parameters")
|
|
|
|
Opens
and
plays
MIDI
sound
file
specified
as
command
parameter.
First
command
parameter
requires
either
a)
folder
path
+
sound
file
name,
or
b)
path
macro
+
sound
file
name
Second
command
parameter
is
optional
and
with
it
you
can
loop
(automatically
repeat)
playback
of
specified
sound
file.
Parameter
is:
LOOP
|
|
|
|
|
**Play
file
MyMusic.mid
from
folder
c:\My
Project
MidiPlay("c:\My
Project\MyMusic.mid")
**Play
file
FourSeasons.mid
from
<SrcDir>
folder
with
looping:
MidiPlay("<SrcDir>\FourSeasons.mid","LOOP")
|
|
|
|
|
Use
CBK
contants
to
retrieve
info
on
opened
sound
file.
If
file
has
not
been
specified
as
command
parameter,
MMB
will
display
Open
File
dialog
box.
Multiple
file
selections
are
enabled
(using
CTRL
and
SHIFT
keys)
-
first
selected
file
will
be
played,
others
are
stored
in
MMB's
internal
Song
List
and
are
retrievable
through
the
<List>
constant.
|
|
|
|
|
|
Stops
playback
of
sound
opened
and
played
by
MidiPlay
command.
No
parameters
required.
|
|
|
|
|
**Stop
midi
sound
playback:
MidiStop()
|
|
|
|
|
|
Opens
MOD
sound
file
specified
as
command
parameter.
Parameter
requires
either
a)
folder
path
+
sound
file
name,
or
b)
path
macro
+
sound
file
name
|
|
|
|
|
**Open
file
MyMusic.mod
from
folder
c:\My
Project
ModOpen("c:\My
Project\MyMusic.mod")
**Open
file
FourSeasons.mod
from
<SrcDir>
folder
ModOpen("
<SrcDir>\FourSeasons.mod")
|
|
|
|
|
Use
CBK
contants
to
retrieve
info
on
opened
sound
file.
If
file
has
not
been
specified
as
command
parameter,
MMB
will
display
Open
File
dialog
box.
Multiple
file
selections
are
enabled
(using
CTRL
and
SHIFT
keys)
-
first
selected
file
will
be
played,
others
are
stored
in
MMB's
internal
Song
List
and
are
retrievable
through
the
<List>
constant.
|
|
|
|
|
|
Plays
MOD
file
opened
using
ModOpen
command.
No
parameters
required.
|
|
|
|
|
**Play
MOD
file:
ModPlay()
|
|
|
|
|
|
Stops
playback
of
sound
opened
and
played
using
ModOpen
and
ModPlay
commands.
No
parameters
required.
|
|
|
|
|
**Stop
MOD
sound
playback:
ModStop()
|
|
|
Audio CD Playback
Commands
|
|
|
|
Starts
playback
of
Audio
CD
from
the
start.
|
|
|
|
|
**Play
Audio
CD
from
the
start
CDPlay()
|
|
|
|
|
|
|
Stops
playback
of
Audio
CD.
|
|
|
|
|
**Stop
Audio
CD
playback
CDStop()
|
|
|
|
|
|
Pause
playback
of
current
Audio
CD
track.
|
|
|
|
|
**Pause
Audio
CD
playback
CDPause()
|
|
|
|
|
|
Plays
Audio
CD
track
specified
using
command
parameter.
Parameter
sets
number
of
track,
for
example:
4
...will
play
Track
4.
|
|
|
|
|
**Play
Audio
CD
track
no.
6
CDTrack("6")
|
|
|
|
|
Mixed-mode
CD's
use
first
track
for
data,
so
first
audio
track
is
Track
2.
|
|
|
|
|
|
Plays
next
Audio
CD
track.
|
|
|
|
|
**Play
next
CDDA
track
CDForward()
|
|
|
|
|
|
Plays
previous
Audio
CD
track.
|
|
|
|
|
**Play
previous
CDDA
track
CDBackward()
|
|
|
|
|
|
Pauses
or
plays
Audio
CD.
If
playback
has
been
paused/stopped,
it
will
be
resumed.
Otherwise
playback
is
paused.
Useful
when
making
one
button
for
play/pause
functions.
|
|
|
|
|
**Play
or
pause
Audio
CD
CDPlayPause()
|
|
|
|
|
|
Sets
position
of
currently
played
Audio
CD
track
10
seconds
forward.
|
|
|
|
|
**Forward
current
Audio
CD
track
CDSkipForward()
|
|
|
|
|
|
Sets
position
of
currently
played
Audio
CD
track
10
seconds
backward.
|
|
|
|
|
**Backward
current
Audio
CD
track
CDSkipBackward()
|
|
|
|
|
|
Retrieves
number
of
currently
played
Audio
CD
track
and
puts
result
into
numerical
variable
specified
as
command
parameter.
Parameter
sets
numerical
variable
that
will
contain
numer
of
played
track.
For
example:
TrackNo
...when
put
into
command,
it
looks
like
this:
WhichCDTrack("TrackNo")
After
performing
code
line
above,
numerical
variable
TrackNo
will
contain
number
of
played
audio
track.
You
can
now,
for
example,
display
it:
Message("Current
Audio
CD
track:","TrackNo")
|
|
|
|
|
**Retrieve
number
of
currently
played
Audio
CD
track
and
display
result
**in
text
object
labeled
"AudioTrack":
WhichCDTrack("TrackNo")
DisplayValue("AudioTrack","TrackNo")
|
|
|
|
|
Mixed-mode
CD's
use
first
track
for
data,
so
first
audio
track
is
Track
2.
|
|
|
Audio Visualization
Commands
|
AudioVisualizationType("ObjectLabel","Type")
|
|
|
|
Sets
type
of
Audio
Visualization.
Uses
two
parameters
-
first
parameter
sets
label
of
Audio
Visualization
object
you
want
settings
be
applied
to.
For
example,
AudioVis
Second
parameter
sets
visualization
type:
|
|
|
|
|
**Set
audio
visualization
object
labeled
MyVis
to
ANALYZER:
AudioVisualizationType("MyVis","ANALYZER")
**Set
audio
visualization
object
labeled
AudioVis
to
**OSCILLOSCOPE:
AudioVisualizationType("AudioVis","OSCILLOSCOPE")
|
|
|
|
|
Audio
visualization
is
supported
for
MP3,
OGG, WAV, XM,
S3M, IT, MOD
files.
|
|
|
AudioVisualizationColor("ObjectLabel","Parameters")
|
|
|
|
Sets
color
of
Audio
Visualization
elements.
First
parameter
sets
label
of
Audio
Visualization
object
you
want
settings
be
applied
to.
For
example,
AudioVis
Second
parameter
sets
visualization
color.
Color
setting
uses
RGB
(
Red,
Green,
Blue)
system
containing
3
components.
Each
component
can
have
one
of
256
levels.
Greater
value
of
component
increases
color
intensity.
If
you
specify
value
0,
color
component
will
not
be
used.
Value
255
uses
maximum
color
intensity.
Color
parameter
for
Audio
Visualization
is
a
comma-separated
array
of
string
values,
each
representing
one
RGB
component
(first:
red,
second:
green,
third:
blue)
in
value
range
0-255.
Both
Analyzer
and
Oscilloscope
visualizations
have
background
color
that
can
be
changed
using
following
parameter:
BACKGROUND=R,G,B
Put
with
numerical
RGB
values:
BACKGROUND=
150,
79,
205
Analyzer
visualization
uses
two
color
settings:
First
you
set
RGB
values
for
bar
color:
RGB(255,0,0)
And
after
comma,
add
RGB
values
for
peak
color:
RGB(0,0,255)
Put
together,
second
parameter
for
analyzer
looks
like
this:
RGB(255,0,0),RGB(0,0,255)
Oscilloscope
visualization
uses
only
one
(line)
color
setting:
Example
of
RGB
values
for
oscilloscope
line
color:
RGB(255,0,0)
|
|
|
|
|
**Set
background
color
of
Audio
Visualization
object
labeled
AudioVis:
AudioVisualizationColor("AudioVis","BACKGROUND=150,79,205")
**Set
Analyzer
bar
and
peak
colors
of
Audio
Visualization
object
**labeled
AudioVis:
AudioVisualizationColor("AudioVis","255,0,0,0,0,255")
**Set
Oscilloscope
line
color
of
Audio
Visualization
object
labeled
AudioVis:
AudioVisualizationColor("AudioVis","255,0,0")
**
an advanced example
with ColorPicker() BGColor$='' ColorPicker() BGColor$=CBK_SelColor If
(BGColor$>'')
Then AudioVisualizationColor("AudioVisualization","BACKGROUND=CBK_SelColor") End
It
opens "Select
Color" dialog
and allow you to
select a color,
then replace the current
BG color with new
selected.
|
|
|
|
|
Audio
visualization
is
supported
for
MP3,
OGG, WAV, XM,
S3M, IT, MOD
files.
|
|
|
|
MMB Scripting Unleashed by
Bokzy, 2003
:: All rights reserved ::
http://www.bokzy.com
|